package ch.janotta.slawo.da.tables;

import ch.janotta.slawo.utilities.Dice;

public final class AttributeValuesTable {
  private static final int[] ATTRIBUTE_RESULTS_TABLE = {
    -2,     // 3d6 ==  3
    -1,     // 3d6 ==  4
    -1,     // 3d6 ==  5
     0,     // 3d6 ==  6
     0,     // 3d6 ==  7
     0,     // 3d6 ==  8
     1,     // 3d6 ==  9
     1,     // 3d6 == 10
     1,     // 3d6 == 11
     2,     // 3d6 == 12
     2,     // 3d6 == 13
     2,     // 3d6 == 14
     3,     // 3d6 == 15
     3,     // 3d6 == 16
     3,     // 3d6 == 17
     4,     // 3d6 == 18
  };

  // Disable the constructor. No instantiation of class possible.
  private AttributeValuesTable() {}

  public static int getRandomAttributeValue() {
    int die1Result = Dice.getD6();
    int die2Result = Dice.getD6();
    int die3Result = Dice.getD6();
    int result = die1Result + die2Result + die3Result;
    int tableIndex = result - 3; // 3d6 starts with 3, array indexes start with 0
    int value = ATTRIBUTE_RESULTS_TABLE[tableIndex];
    return value;
  }
}
